﻿using com.guojin.core.io.message;
using com.guojin.mj.net.message.login;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class RoomCard
{
    private static RoomCard instance;
    public static RoomCard GetInstance()
    {
        if (instance == null)
        {
            instance = new RoomCard();
        }
        return instance;
    }

    private int _gold;

    //监听房卡属性，发生改变同步至大厅
    public int gold
    {
        get { return _gold; }
        set
        {
            _gold = value;
            RoomCardPropertyChange(_gold);
        }
    }

    public void OnReceiveMsg713(string msg, Message data)
    {
        var roomCardRet = (RoomCardRet)data;
        SyncRoomCard(roomCardRet.roomCard);
    }

    public void SyncRoomCard(int counts)
    {
        gold = counts;
    }

    public void AddRoomCard(int counts)
    {
        gold += counts;
    }

    public void SubRoomCard(int counts)
    {
        gold -= counts;
    }

    private void RoomCardPropertyChange(int _gold)
    {
        GameData.GetInstance().gold = _gold;
    }
}
